<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
#div1{width: 100px;height: 30px;background: red;}
</style>
<script>
window.onload = function(){
    var oDiv = document.getElementById('div1');

    var timer = null;
    var iSpeed = 0;
    oDiv.onmouseover = function(){
       startMove(300);
    };

    oDiv.onmouseout = function(){
       startMove(30);
    };

    function startMove(iTarget){
        clearInterval(timer);

        timer = setInterval(function(){
           iSpeed += (iTarget - oDiv.offsetHeight)/6;
           iSpeed *= 0.75;

           if(Math.abs(iSpeed)<=1 && Math.abs(iTarget - oDiv.offsetHeight)<=1){
              clearInterval(timer);
              iSpeed = 0;
              oDiv.style.height = iTarget + 'px';
           }else{
              var H = oDiv.offsetHeight + iSpeed;

              if(H < 0){
                   H = 0;
              }
              oDiv.style.height = H + 'px';
           }
        },30)
    }
}

</script>
<title>运动</title>
</head>
<body>
    <div id="div1"></div>
</body>
</html>